<?php

class Message extends AppModel {

/**
 * Name
 *
 * @var string
 */
    public $name = "Message";
    public $useTable = "templates";

/**
 * Validation rules
 *
 * @var string
 **/    
    public $validate = array(
        'title' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'The title is required'
            )
        )
    );
    
    const SEND_VOUCHER_WHEN_REACH_1000 = 8;
    const SEND_VOUCHER = 9;
    const CUSTOMER_RECEIVE_POINT_FROM_FRIEND = 10;
    const SEND_QR_CODE = 11;
    const SEND_MAIL_REGISTER = 12;
    const CUSTOMER_REQUEST_QR_CODE = 13;
    const NEW_SURVEY_ADDED = 14;

    public static function get_template($type){
        $temp = ClassRegistry::init('Message');
        $template = $temp->find('first', array('conditions' => array('id' => $type)));
        if(!empty($template)){
            return $template['Message']['message_en'];
        }
        return '';
    }
    public function getTemplateById($template_id,$language) {
        $temp = ClassRegistry::init('Message');
        $template = $temp->find('first', array('conditions' => array('id' => $template_id)));
        if(!empty($template)){
            if($language=="en"){
                return $template['Message']['message_en'];
            }else{
                return $template['Message']['message_ar'];
            }
            
        }
        return '';
    }
}